﻿/**
* 
* @author Chen
* @version 1.0
*
*/
angular.module("ng-unvs-store", [])
.service("$store", [function () {
    return {
        $clear: function (key) {
            if (!key) {
                Windows.Storage.ApplicationData.current.localSettings.values.clear();
            }
            else {
                Windows.Storage.ApplicationData.current.localSettings.values.remove(key);
            }
        },
        $set: function (key, data) {
            Windows.Storage.ApplicationData.current.localSettings.values[key] = JSON.stringify(data);
        },
        $get: function (key) {
            var txt = Windows.Storage.ApplicationData.current.localSettings.values[key];
            if (!txt) return undefined;
            if (txt == null) return undefined;
            if (txt == "") return undefined;

            return Function("", "return " + txt + ";")();
        }

    }
}]);